package com.itzjc.controller;

import com.itzjc.domain.entity.Result;
import com.itzjc.domain.pojo.*;
import com.itzjc.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * TODO
 *
 * @className: BaseController
 * @date: 2022-04-22 19:32
 **/
@RestController
@RequestMapping("/web/api/v1/pri/base")
public class BaseTestController{
    @Autowired
    private BaseService baseTestService;

    /**
    *  本接口就是没有连接数据库测试3层有没有写错的，太久没用SpringBoot以免3层之间的通信写错了
    * @param request
    * @return:
    **/
    @GetMapping("/getTest")
    public Result getTest(HttpServletRequest request) {
        String testString = baseTestService.getTestString();
        return Result.buildSuccess("获取列表成功", testString);
    }

    /**
    * 获取传感器基本信息列表
    * @param
    * @return:
    **/

    @GetMapping("/getSensor")
    public Result getSensor() {

        List<Sensor> SensorList = baseTestService.getSensorList();

        return Result.buildSuccess("获取列表成功", SensorList);
    }

    /**
    *
    默认情况下获取200条Data表最新数据
    * @return:
    **/

    @GetMapping("/getDataDefault")
    public Result getDataDefault() {

        List<Data> dataDefaultList = baseTestService.getDataDefault();

        return Result.buildSuccess("获取列表成功", dataDefaultList);
    }

    /**
    * 前端指定获取指定数目的Data表最新数据
    * @param number
    * @return:
    **/

    @GetMapping("/getDataByNumber")
    public Result getDataByNumber(int number) {

        List<Data> dataByNumberList = baseTestService.getDataByNumberList(number);

        return Result.buildSuccess("获取列表成功", dataByNumberList);
    }

    /**
     *
     默认情况下获取200条DataAction表最新数据
     * @return:
     **/

    @GetMapping("/getDataActionDefault")
    public Result getDataActionDefault() {

        List<DataAction> dataActionDefaultList = baseTestService.getDataActionDefault();

        return Result.buildSuccess("获取列表成功", dataActionDefaultList);
    }

    /**
     * 前端指定获取指定数目的DataAction表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getDataActionByNumber")
    public Result getDataActionByNumber(int number) {

        List<DataAction> dataActionByNumberList = baseTestService.getDataActionByNumberList(number);

        return Result.buildSuccess("获取列表成功", dataActionByNumberList);
    }
    /**
     *
     默认情况下获取200条DataDay表最新数据
     * @return:
     **/

    @GetMapping("/getDataDayDefault")
    public Result getDataDayDefault() {

        List<DataDay> dataDayDefaultList = baseTestService.getDataDayDefault();

        return Result.buildSuccess("获取列表成功", dataDayDefaultList);
    }

    /**
     * 前端指定获取指定数目的DataDay表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getDataDayByNumber")
    public Result getDataDayByNumber(int number) {

        List<DataDay> dataDayByNumberList = baseTestService.getDataDayByNumberList(number);

        return Result.buildSuccess("获取列表成功", dataDayByNumberList);
    }
    /**
     *
     默认情况下获取200条DataHour表最新数据
     * @return:
     **/

    @GetMapping("/getDataHourDefault")
    public Result getDataHourDefault() {

        List<DataHour> dataHourDefaultList = baseTestService.getDataHourDefault();

        return Result.buildSuccess("获取列表成功", dataHourDefaultList);
    }

    /**
     * 前端指定获取指定数目的DataHour表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getDataHourByNumber")
    public Result getDataHourByNumber(int number) {

        List<DataHour> dataHourByNumberList = baseTestService.getDataHourByNumberList(number);

        return Result.buildSuccess("获取列表成功", dataHourByNumberList);
    }
    /**
     *
     默认情况下获取200条DataMinute表最新数据
     * @return:
     **/

    @GetMapping("/getDataMinuteDefault")
    public Result getDataMinuteDefault() {

        List<DataMinute> dataMinuteDefaultList = baseTestService.getDataMinuteDefault();

        return Result.buildSuccess("获取列表成功", dataMinuteDefaultList);
    }

    /**
     * 前端指定获取指定数目的DataMinute表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getDataMinuteByNumber")
    public Result getDataMinuteByNumber(int number) {

        List<DataMinute> dataMinuteByNumberList = baseTestService.getDataMinuteByNumberList(number);

        return Result.buildSuccess("获取列表成功", dataMinuteByNumberList);
    }
    /**
     *
     默认情况下获取200条DataTMinute表最新数据
     * @return:
     **/

    @GetMapping("/getDataTMinuteDefault")
    public Result getDataTMinuteDefault() {

        List<DataTMinute> dataTMinuteDefaultList = baseTestService.getDataTMinuteDefault();

        return Result.buildSuccess("获取列表成功", dataTMinuteDefaultList);
    }

    /**
     * 前端指定获取指定数目的DataTMinute表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getDataTMinuteByNumber")
    public Result getDataTMinuteByNumber(int number) {

        List<DataTMinute> dataTMinuteByNumberList = baseTestService.getDataTMinuteByNumberList(number);

        return Result.buildSuccess("获取列表成功", dataTMinuteByNumberList);
    }
    /**
     *
     默认情况下获取200条DataWeek表最新数据
     * @return:
     **/

    @GetMapping("/getDataWeekDefault")
    public Result getDataWeekDefault() {

        List<DataWeek> dataWeekDefaultList = baseTestService.getDataWeekDefault();

        return Result.buildSuccess("获取列表成功", dataWeekDefaultList);
    }

    /**
     * 前端指定获取指定数目的DataWeek表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getDataWeekByNumber")
    public Result getDataWeekByNumber(int number) {

        List<DataWeek> dataWeekByNumberList = baseTestService.getDataWeekByNumberList(number);

        return Result.buildSuccess("获取列表成功", dataWeekByNumberList);
    }
    /**
     *
     默认情况下获取200条Display表最新数据
     * @return:
     **/

    @GetMapping("/getDisplayDefault")
    public Result getDisplayDefault() {

        List<Display> displayDefaultList = baseTestService.getDisplayDefault();

        return Result.buildSuccess("获取列表成功", displayDefaultList);
    }

    /**
     * 前端指定获取指定数目的Display表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getDisplayByNumber")
    public Result getDisplayByNumber(int number) {

        List<Display> displayByNumberList = baseTestService.getDisplayByNumberList(number);

        return Result.buildSuccess("获取列表成功", displayByNumberList);
    }
    /**
     *
     默认情况下获取200条SensorGroup表最新数据
     * @return:
     **/

    @GetMapping("/getSensorGroupDefault")
    public Result getSensorGroupDefault() {

        List<SensorGroup> sensorGroupDefaultList = baseTestService.getSensorGroupDefault();

        return Result.buildSuccess("获取列表成功", sensorGroupDefaultList);
    }

    /**
     * 前端指定获取指定数目的SensorGroup表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getSensorGroupByNumber")
    public Result getSensorGroupByNumber(int number) {

        List<SensorGroup> sensorGroupByNumberList = baseTestService.getSensorGroupByNumberList(number);

        return Result.buildSuccess("获取列表成功", sensorGroupByNumberList);
    }
    /**
     *
     默认情况下获取200条SensorValue表最新数据
     * @return:
     **/

    @GetMapping("/getSensorValueDefault")
    public Result getSensorValueDefault() {

        List<SensorValue> sensorValueDefaultList = baseTestService.getSensorValueDefault();

        return Result.buildSuccess("获取列表成功", sensorValueDefaultList);
    }

    /**
     * 前端指定获取指定数目的SensorValue表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getSensorValueByNumber")
    public Result getSensorValueByNumber(int number) {

        List<SensorValue> sensorValueByNumberList = baseTestService.getSensorValueByNumberList(number);

        return Result.buildSuccess("获取列表成功", sensorValueByNumberList);
    }
    /**
     *
     默认情况下获取200条WarningTable表最新数据
     * @return:
     **/

    @GetMapping("/getWarningTableDefault")
    public Result getWarningTableDefault() {

        List<WarningTable> warningTableDefaultList = baseTestService.getWarningTableDefault();

        return Result.buildSuccess("获取列表成功", warningTableDefaultList);
    }

    /**
     * 前端指定获取指定数目的WarningTable表最新数据
     * @param number
     * @return:
     **/

    @GetMapping("/getWarningTableByNumber")
    public Result getWarningTableByNumber(int number) {

        List<WarningTable> warningTableByNumberList = baseTestService.getWarningTableByNumberList(number);

        return Result.buildSuccess("获取列表成功", warningTableByNumberList);
    }



}
